package com.itheima.a01staticdemo3;

import java.util.ArrayList;

public class StudentUtil {
    //私有化构造方法
    private StudentUtil() {

    }

    //需要定义为静态的，方便使用
    public static int getMaxage(ArrayList<Student3> list) {
        //1.定义一个参照物
        int max = list.get(0).getAge();

        //2.循环遍历集合
        for (int i = 1; i < list.size(); i++) {
            int age = list.get(i).getAge();
            if (age > max) {
                max = age;
            }
        }
        //3.直接返回max
        return max;
    }
}
